package net.lb.socketserver.transfer.server;

import net.lb.beancontext.core.BeanContextImpl;
import net.lb.beancontext.core.bean.BeanConfig;
import net.lb.socketserver.handler.impl.auth.AuthHandler;
import net.lb.socketserver.util.HeadFactory;

/**
 * 对称加密方式采用des加密方式的服务器
 * 
 * @author 林斌（windfire@zailanghua.com）
 * 
 */
public class DesServerMain extends ServerMain
{
    public DesServerMain(ServerConfig serverConfig, BeanConfig... beanConfigs)
    {
        this.serverConfig = serverConfig;
        serverConfig.addPackageNames("net.lb.socketserver");
        beanContext = new BeanContextImpl(serverConfig.getPackageNames());
        for (BeanConfig each : beanConfigs)
        {
            beanContext.addBeanConfig(each);
        }
        beanContext.addSingletonEntity(ServerConfig.class.getName(), serverConfig);
        beanContext.addSingletonEntity(HeadFactory.class.getName(), serverConfig.getHeadFactory());
        beanContext.initContext();
        aioServer = beanContext.getBeanByOriginType(AioServer.class);
        AuthHandler authHandler = beanContext.getBeanByOriginType(AuthHandler.class);
        authHandler.setPublicKey(serverConfig.getPublicKey());
    }
}
